import Vue from 'vue'
import Router from 'vue-router'
import routers from './routers'

Vue.use(Router)

/**
 * constantRoutes
 *没有权限要求的基本页面
 *所有角色都可以访问
 */
export const constantRoutes = routers

const createRouter = () =>
  new Router({
    // mode: 'history', // 需要服务支持
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // 重置 路由
}

export default router
